function x_cup = stateTransition(x_cu,model)

if model.pruningOn == 1   
    % note that x_cu and xAll_cup are in dev from steady state.
    if model.appOrder == 1
        xf_cu      = x_cu(1:model.nx,1);
        xf_cup     = model.hx*xf_cu;
        xAll_cup   = xf_cup;
    elseif model.appOrder == 2
        xf_cu                 = x_cu(1:model.nx,1);
        xs_cu                 = zeros(model.nx,1);
        xs_cu(1:model.nx1,1)  = x_cu(model.nx+1:model.nx+model.nx1,1);
        xfxf_cu               = kron3(xf_cu,xf_cu);
        xf_cup                = model.hx*xf_cu;
        xs_2nx1_cup           = model.hx(1:model.nx1,:)*xs_cu + model.Hxx(1:model.nx1,:)*xfxf_cu + 0.5*model.hss(1:model.nx1,:);
        xAll_cup              = [xf_cup;xs_2nx1_cup];
    elseif model.appOrder == 3
        xf_cu                 = x_cu(1:model.nx,1);
        xs_cu                 = zeros(model.nx,1);
        xs_cu(1:model.nx1,1)  = x_cu(model.nx+1:model.nx+model.nx1,1);
        xrd_cu                = zeros(model.nx,1);
        xrd_cu(1:model.nx1,1) = x_cu(model.nx+model.nx1+1:model.nx+2*model.nx1,1);
        xfxf_cu               = kron3(xf_cu,xf_cu);
        xfxs_cu               = kron3(xf_cu,xs_cu);
        xf_cup                = model.hx*xf_cu;
        xs_2nx1_cup           = model.hx(1:model.nx1,:)*xs_cu  + model.Hxx(1:model.nx1,:)*xfxf_cu + 0.5*model.hss(1:model.nx1,:);
        xrd_2nx1_cup          = model.hx(1:model.nx1,:)*xrd_cu + 2*model.Hxx(1:model.nx1,:)*xfxs_cu ...
                                +  model.Hxxx(1:model.nx1,:)*kron3(xf_cu,xfxf_cu) + +3/6*model.hssx(1:model.nx1,:)*xf_cu;
        xAll_cup              = [xf_cup;xs_2nx1_cup;xrd_2nx1_cup];
    end
    x_cup = xAll_cup;
else
    x_cup = zeros(model.nx,1);
    if model.appOrder == 1
        x_cup(1:model.nx1,1) = model.hx(1:model.nx1,:)*x_cu;
    elseif model.appOrder == 2
        x_cup(1:model.nx1,1) = model.hx(1:model.nx1,:)*x_cu + model.Hxx(1:model.nx1,:)*kron3(x_cu,x_cu) + 0.5*model.hss(1:model.nx1,:);
    elseif model.appOrder == 3
        x_cup(1:model.nx1,1) = model.hx(1:model.nx1,:)*x_cu ...
            + model.Hxx(1:model.nx1,:)*kron3(x_cu,x_cu) ...
            + model.Hxxx(1:model.nx1,:)*kron3(x_cu,kron3(x_cu,x_cu)) ...
            + 0.5*model.hss(1:model.nx1,:) + 3/6*model.hssx(1:model.nx1,:)*x_cu;
    end
    x_cup(model.nx1+1:model.nx,1) = model.hx(model.nx1+1:model.nx,:)*x_cu;
end

end